<template>
  <template v-if="column.children?.length">
    <vxe-colgroup :title="column.title">
      <template v-for="j in column.children" :key="j.field">
        <ColumnItem :column="j" v-bind="j">
          <template v-for="(_, slotName) in $slots" #[slotName]="scope">
            <slot :name="slotName" v-bind="scope" />
          </template>
        </ColumnItem>
      </template>
    </vxe-colgroup>
  </template>

  <template v-else>
    <vxe-column v-bind="column">
      <template #default="{ row, rowIndex }" v-if="$slots[column.field]">
        <slot :name="column.field" :row="row" :index="rowIndex" />
      </template>
      <template #content="{ row, rowIndex }" v-else>
        <slot name="expand" :row="row" :index="rowIndex" />
      </template>
    </vxe-column>
  </template>
</template>
<script setup>
defineProps({
  column: {
    type: Object,
    default: () => { },
  },
})
</script>
<style lang="scss" scoped></style>
